<template>
  <div class="edit">
    <div class="edit-title">
      <span class="title-1">学习中心</span> /
      <span class="title-1">我的专题培训</span> /
      <span class="title-2">理论考试</span>
    </div>
    <div class="edit-content">
      <div class="edit-content-left">
        <div class="edit-content-left-title">{{ examInfo.examId }}</div>
        <div class="edit-content-left-content">
          <div
            class="edit-content-left-content-item2"
            v-for="(currentQuestion, currentIndex) in listData"
            :key="currentIndex"
          >
            <!-- <div>{{ currentIndex + 1 }}.{{ currentQuestion.title }}</div> -->
            <!-- 判断题 -->
            <div class="examination-content" v-if="currentQuestion.questionType == 'determine'" :key="currentIndex">
              <div class="examination-content-t">
                <div class="examination-content-t-t">{{ currentIndex + 1 }}、{{ currentQuestion.title }}</div>
                <div class="examination-content-t-t"
                  v-if="currentQuestion.titleImgs && JSON.parse(currentQuestion.titleImgs).length > 0">
                  <img v-for="(item, index) in JSON.parse(currentQuestion.titleImgs)" :key="index" :src="define.comUrl+item" />
                </div>
                <div :class="['examination-content-t-c', currentQuestion.isAnswers == 1 && currentQuestion.answers == JSON.parse(currentQuestion.options)[currentQuestion.myAnswers].content ? 'success' : 'error']">
                  <div :class="['edit-content-right-item-2', option.myanswer ? 'choose' : '']"
                    v-for="(option, i) in JSON.parse(currentQuestion.options)" :key="i">
                    {{ option.title }}
                  </div>
                </div>
              </div>
            </div>
            <!-- 填空题 -->
            <div class="examination-content1" v-if="currentQuestion.questionType == 'blank'" :key="currentIndex">
              <div class="examination-content-t">
                <div class="examination-content-t-t">{{ currentIndex + 1 }}、{{ currentQuestion.title }}</div>
                <div class="examination-content-t-t"
                  v-if="currentQuestion.titleImgs && JSON.parse(currentQuestion.titleImgs).length > 0">
                  <img v-for="(item, index) in JSON.parse(currentQuestion.titleImgs)" :key="index" :src="define.comUrl+item" />
                </div>
                <div class="examination-content-t-c1">
                  <div v-for="(option, i) in JSON.parse(currentQuestion.options)" :key="i"
                    :class="['fillList', currentQuestion.isAnswers == 1 && option == JSON.parse(currentQuestion.myAnswers)[i] ? 'success' : 'error']">
                    <div>填空1</div>
                    <div class="uni-input">{{ JSON.parse(currentQuestion.myAnswers)[i] }}</div>
                  </div>
                </div>
              </div>
            </div>
            <!-- 选择题 -->
            <div class="examination-content2" v-if="currentQuestion.questionType == 'multiple'" :key="currentIndex">
              <div class="examination-content-t">
                <div class="examination-content-t-t">{{ currentIndex + 1 }}、{{ currentQuestion.title }}</div>
                <div class="examination-content-t-t"
                  v-if="currentQuestion.titleImgs && JSON.parse(currentQuestion.titleImgs).length > 0">
                  <img v-for="(item, index) in JSON.parse(currentQuestion.titleImgs)" :key="index" :src="define.comUrl+item" />
                </div>
                <div :class="['examination-content-t-c2']">
                  <div class="edit-content-right-item-2" v-for="(option, i) in JSON.parse(currentQuestion.options)" :key="i"
                    :class="[{ 'choose': option.myanswer }, { 'success': option.isanswer}, { 'error': !option.isanswer }]">
                    <span>{{ option.label }}</span>
                    <span style="padding-left: 16px;">{{ option.content }}</span>
                    <div style="flex: 1; padding-left: 16px;" v-if="option.img && option.img.length > 0">
                      <img v-for="(item, index) in option.img" :key="index" :src="define.comUrl+item" />
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!-- 问答题 -->
            <div class="examination-content2" v-if="currentQuestion.questionType == 'answers'" :key="currentIndex">
              <div class="examination-content-t">
                <div class="examination-content-t-t">{{ currentIndex + 1 }}、{{ currentQuestion.title }}</div>
                <div class="examination-content-t-t"
                  v-if="currentQuestion.titleImgs && JSON.parse(currentQuestion.titleImgs).length > 0">
                  <img v-for="(item, index) in JSON.parse(currentQuestion.titleImgs)" :key="index" :src="define.comUrl+item" />
                </div>
                <div class="examination-content-t-c2">
                  <div :class="['uni-input', currentQuestion.isAnswers == 1 && currentQuestion.myAnswers == currentQuestion.answers ? 'success' : 'error']">{{ currentQuestion.myAnswers }}</div>
                </div>
              </div>
            </div>
            <!-- <div
              v-for="(it, i) in JSON.parse(item.options)"
              class="edit-content-left-content-item2-list"
              :class="
                item.daan !== item.choose && item.daan - 1 === i
                  ? 'active-item'
                  : ''
              "
              :key="i"
            >
              <div>{{ it.title }}</div>
              <div v-if="item.daan !== item.choose && item.daan - 1 === i">
                <img src="../../assets/images/err-choose.png" />
              </div>
            </div> -->
          </div>
        </div>
      </div>
    </div>
    <div class="radio-btn">
      <el-button @click="submitItem">关闭</el-button>
    </div>
  </div>
</template>
<script>
import { analysisExamTask } from '@/api/exam';

export default {
  data() {
    return {
      types: this.$route.query.type,
      labelPosition: "top",
      formLabelAlign: {
        name: "",
        region: "",
      },
      examInfo: {
        examId: ''
      },
      listData: [
        // {
        //   namelist: [
        //     "A.兴修水利",
        //     "B.粪便污染水源",
        //     "C.改水改厕",
        //     "D.对饮用水",
        //   ],
        //   daan: 1,
        //   choose: 2,
        // },
        // {
        //   namelist: [
        //     "A.兴修水利",
        //     "B.粪便污染水源",
        //     "C.改水改厕",
        //     "D.对饮用水",
        //   ],
        //   daan: 1,
        //   choose: 2,
        // },
      ],
    };
  },
  created(){
    this.getList();
  },
  methods: {
    submitItem() {

      if (this.types == 1) {
        // 我的考试
        this.$router.push({
          path: "/exam/myexam",
          // query: {
          // },
        });
      }
      else {
        // this.$router.go(-2);
        this.$router.push({
          path: "/myTrain/index",
          // query: {
          // },
        });
      }

    },
    getList(){
      const id = this.$route.query.id;
      analysisExamTask(id).then(res => {
        console.log(res);
        if(res.code == 200){
          this.examInfo = res.data;
          this.listData = res.data.temsexamtaskresultList;
        }else{
          this.$message.error(res.msg);
        }
      })
    }
  },
};
</script>
<style lang="scss" scoped>
.examination-content {
    width: 100%;
    height: auto;
    box-sizing: border-box;
    padding: 0 16px;
  
    .examination-content-t {
      width: 100%;
      height: 100%;
      background-color: #F6F7FB;
  
      .examination-content-t-t {
        padding: 16px 16px 0;
      }
  
      .examination-content-t-h {
        padding-top: 24px;
        display: flex;
        justify-content: center;
        align-items: center;
  
        view:nth-child(1) {
          text-align: left;
          width: 74px;
          height: 32px;
          background-color: #000;
          color: #fff;
          text-align: center;
          line-height: 32px;
          border-radius: 0 100px 100px 0;
        }
  
        view:nth-child(2) {
          flex: 1;
          font-weight: 500;
          font-size: 12px;
          color: #101112;
          line-height: 18px;
          text-align: right;
          font-style: normal;
          margin-right: 13px;
        }
      }
  
      .examination-content-t-c {
        width: 100%;
        height: auto;
        box-sizing: border-box;
        padding: 0 16px 16px;
        margin-top: 16px;
  
        .edit-content-right-item-2 {
          padding: 8px 30px;
          background-color: #fff;
          border-radius: 5px;
          margin-bottom: 10px;
          position: relative;
        }
  
      }
      
      .examination-content-t-c.success {
        
        .edit-content-right-item-2.choose {
          border: 1px solid green;
        }
        .edit-content-right-item-2.choose::after {
          position: absolute;
          right: 10px;
          top: 50%;
          transform: translate(0, -50%);
          color: green;
          content: "✔";
          font-weight: 600;
        }
      }
          
      .examination-content-t-c.error {
        
        .edit-content-right-item-2.choose {
          border: 1px solid red;
        }
        .edit-content-right-item-2.choose::after {
          position: absolute;
          right: 10px;
          top: 50%;
          transform: translate(0, -50%);
          color: red;
          content: "×";
          font-weight: 600;
          font-size: 20px;
        }
      }
    }
  }
  
  .examination-content1 {
    width: 100%;
    box-sizing: border-box;
    padding: 0 16px;
  
    .examination-content-t {
      width: 100%;
      height: auto;
      background-color: #F6F7FB;
  
      .examination-content-t-t {
        padding: 16px 16px 0;
      }
  
      .examination-content-t-h {
        padding-top: 24px;
        display: flex;
        justify-content: center;
        align-items: center;
  
        view:nth-child(1) {
          text-align: left;
          width: 74px;
          height: 32px;
          background-color: #000;
          color: #fff;
          text-align: center;
          line-height: 32px;
          border-radius: 0 100px 100px 0;
        }
  
        view:nth-child(2) {
          flex: 1;
          font-weight: 500;
          font-size: 12px;
          color: #101112;
          line-height: 18px;
          text-align: right;
          font-style: normal;
          margin-right: 13px;
        }
      }
  
      .examination-content-t-c1 {
        width: 100%;
        height: auto;
        box-sizing: border-box;
        padding: 0 16px 16px;
        margin-top: 16px;
  
        .fillList {
          display: flex;
          align-items: center;
          background-color: #fff;
          padding: 3px 8px;
          border-radius: 5px;
          position: relative;
          
          .uni-input {
            height: 40px;
            line-height: 40px;
            padding-left: 24px;
          }
        }
  
        .fillList.success {
          border: 1px solid green;
        }
        .fillList.success::after {
          position: absolute;
          right: 20px;
          top: 50%;
          transform: translate(0, -50%);
          color: green;
          content: "✔";
          font-weight: 600;
        }
  
        .fillList.error {
          border: 1px solid red;
        }
        .fillList.error::after {
          position: absolute;
          right: 20px;
          top: 50%;
          transform: translate(0, -50%);
          color: red;
          content: "×";
          font-weight: 600;
          font-size: 20px;
        }
  
        .c-t {
          image {
            border-radius: 8px;
            width: 100%;
            height: 174px;
          }
        }
  
        .c-t1 {
          display: flex;
          justify-content: center;
          align-items: center;
          box-sizing: border-box;
          padding: 16px;
  
          view:nth-child(1) {
            flex: 2;
          }
  
          view:nth-child(2) {
            flex: 10;
  
            image {
              border-radius: 8px;
              width: 100%;
              height: 142px;
            }
          }
        }
      }
    }
  }
  

.examination-content2 {
  width: 100%;
  box-sizing: border-box;
  padding: 0 16px;
  overflow: auto;

  .examination-content-t {
    width: 100%;
    height: auto;
    background-color: #F6F7FB;

    .examination-content-t-t {
      padding: 16px 16px 0;
    }

    .examination-content-t-h {
      padding-top: 24px;
      display: flex;
      justify-content: center;
      align-items: center;

      view:nth-child(1) {
        text-align: left;
        width: 74px;
        height: 32px;
        background-color: #000;
        color: #fff;
        text-align: center;
        line-height: 32px;
        border-radius: 0 100px 100px 0;
      }

      view:nth-child(2) {
        flex: 1;
        font-weight: 500;
        font-size: 12px;
        color: #101112;
        line-height: 18px;
        text-align: right;
        font-style: normal;
        margin-right: 13px;
      }
    }

    .examination-content-t-c2 {
      width: 100%;
      height: auto;
      box-sizing: border-box;
      background-color: #F6F7FB;
      box-sizing: border-box;
      padding: 16px 16px;

      .edit-content-right-item-2 {
        padding: 8px 16px;
        background-color: #fff;
        margin-bottom: 10px;
        border-radius: 5px;
        display: flex;
        align-items: center;
        border: 1px solid #fff;
        position: relative;
      }

      .edit-content-right-item-2.choose.success {
        border: 1px solid green;
      }
      .edit-content-right-item-2.choose.success::after {
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translate(0, -50%);
        color: green;
        content: "✔";
        font-weight: 600;
      }
      .edit-content-right-item-2.choose.error {
        border: 1px solid red;
      }
      .edit-content-right-item-2.choose.error::after {
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translate(0, -50%);
        color: red;
        content: "×";
        font-weight: 600;
        font-size: 20px;
      }

      .uni-input {
        height: 80px;
        border-radius: 5px;
        padding: 8px 16px;
        position: relative;
      }
      .uni-input.success {
        border: 1px solid green;
      }
      .uni-input.success::after {
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translate(0, -50%);
        color: green;
        content: "✔";
        font-weight: 600;
      }
      .uni-input.choose.error::after {
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translate(0, -50%);
        color: red;
        content: "×";
        font-weight: 600;
        font-size: 20px;
      }
    }
  }
}

	


.edit {
  box-sizing: border-box;
  height: 100%;
  position: relative;
  padding: 12px;
  .edit-title {
    font-weight: 500;
    font-size: 14px;
    color: #536387;
    line-height: 29px;
    text-align: left;
    font-style: normal;
    .title-1 {
      color: #536387;
      padding-right: 11px;
    }
    .title-2 {
      padding-left: 11px;
      color: #323232;
    }
  }
}
.edit-content {
  display: flex;
  margin-top: 24px;
  .edit-content-left {
    flex: 8;
    background: #fff;
    box-sizing: border-box;
    padding: 24px 24px 80px 24px;
    height: calc(100vh - 200px);
    overflow: auto;
    .edit-content-left-title {
      width: 100%;
      height: 50px;
      font-size: 24px;
      text-align: center;
      border-bottom: 1px solid #f0f2fa;
    }
  }
  .edit-content-right {
    flex: 4;
    margin-left: 20px;
    background: #fff;
    box-sizing: border-box;
    padding: 24px;
    position: relative;
    .edit-content-right-title {
      width: 100%;
      height: 50px;
      font-size: 18px;
      line-height: 50px;
      border-bottom: 1px solid #f0f2fa;
      display: flex;
      div:nth-child(1) {
        flex: 8;
      }
      div:nth-child(2) {
        flex: 4;
      }
    }
    .edit-content-right-content {
      .edit-content-right-item {
        margin-top: 12px;
        width: 100%;
        height: 50px;
        line-height: 50px;
        font-size: 16px;
        position: relative;
        padding-left: 16px;
        &:before {
          content: "";
          width: 4px;
          height: 20px;
          position: absolute;
          left: 0;
          top: 16px;
          background: #2265ee;
        }
      }
      .edit-content-right-item-1 {
        margin-top: 24px;
        display: flex;
        .edit-content-right-item-2 {
          width: 100px;
          height: 40px;
          line-height: 40px;
          text-align: center;
          border: 1px solid #2265ee;
          color: #2265ee;
          margin-right: 10px;
          border-radius: 4px;
          font-size: 14px;
        }
      }
    }
  }
}
.edit-content-right-btn {
  width: 90%;
  position: absolute;
  bottom: 30px;
  display: flex;
  .el-button {
    width: 80%;
    height: 40px;
  }
  .el-button:nth-child(2) {
    background: #2265ee;
    color: #fff;
    border: 1px solid #2265ee;
    &:active {
      opacity: 0.8;
    }
  }
}
.edit-content-left-content {
  width: 100%;
}
.edit-content-left-content-item1 {
  display: flex;
  margin-top: 24px;
  font-size: 24px;
  width: 100%;
  div:nth-child(1) {
    flex: 8;
    text-align: left;
  }
  div:nth-child(2) {
    flex: 4;
    text-align: right;
  }
}
.edit-content-left-content-item2 {
  margin-top: 24px;
  font-size: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e6e6e6;
  img {
    width: 260px;
    height: 140px;
  }
}
.edit-content-left-content-item2-list {
  padding-left: 32px;
  max-width: 400px;
  height: 44px;
  line-height: 44px;
  display: flex;
  margin-top: 10px;
  div:nth-child(1) {
    flex: 8;
  }
  div:nth-child(2) {
    flex: 4;
    text-align: right;
    img {
      margin-top: 8px;
      width: 24px;
      height: 24px;
      margin-right: 8px;
    }
  }
}
.edit-content-left-content-item2-2 {
  padding-left: 32px;
  div {
    margin-top: 32px;
    img {
      width: 100%;
      height: 300px;
    }
  }
}
.edit-content-left-content-item2-1 {
  display: flex;

  width: 100%;

  height: 100px;

  border-radius: 4px;

  margin-top: 20px;

  justify-content: space-around;

  align-items: center;

  flex-wrap: wrap; //设置换行

  gap: 10px; //每个元素间隔10px
  div {
    border: 1px solid #f1f4fb;
    display: flex;

    border-radius: 5px;

    justify-content: space-around;

    align-items: center;

    width: calc(50% - 20px); //设置所占宽度50%，再减去20px

    padding: 10px;

    box-sizing: border-box; //设置后宽高不变，不会因为间隔而变小
  }
}
.active-item {
  border: 1px solid #d91515 !important;
  color: #d91515 !important;
}
.radio-btn {
  width: 100%;
  height: 76px;
  background-color: #fff;
  position: absolute;
  bottom: 0;
  text-align: right;

  .el-button {
    margin-top: 20px;
    margin-right: 20px;
    width: 106px;
    height: 36px;
    background-color: #2265ee;
    border: 1px solid #2265ee;
    color: #fff;
    &:active {
      opacity: 0.8;
    }
  }
}
</style>
